package net.crowdloud.client.user;

import net.crowdloud.shared.entities.User;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public class GetUser {

	public GetUser(User user) {

		final UserDatabaseServerCallsAsync databaseServerCalls = GWT
				.create(UserDatabaseServerCalls.class);

		databaseServerCalls.getUser(user.getUserID(),
				new AsyncCallback<User>() {

					public void onSuccess(User user) {

						RootPanel.get().clear();
						RootPanel.get().add(new UserPage(user, null));
					}

					public void onFailure(Throwable caught) {
						// Show the RPC error message to the user

					}

				});

	}

}
